package com.gome.han.bigdata.spark.core.rdd.operation.transformation

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD

/**
 * @author Hanpeng
 * @date 2021/1/12 21:14
 * @description:
 */
object MapOperationLogDemo {
  def main(args: Array[String]): Unit = {
    //TODO 准备环境
    val sparkConf:SparkConf = new SparkConf();
    sparkConf.setMaster("local[*]").setAppName("operationMap");
    val sparkContext:SparkContext = new SparkContext(sparkConf);
    //TODO 创建RDD

    val lines: RDD[String] = sparkContext.textFile("in/apache.log");
    val pathRdd: RDD[String] = lines.map((line: String) => {
      val datas = line.split(" ")
      datas(6)
    })
    pathRdd.collect().foreach(println)
    // TODO 关闭环境
    sparkContext.stop()
  }
}
